/**
@author		Jong Min, Lee
@date		  02/10/2014
@breif		study view class

copyright(c) Tae Young Soft. All right reserved. 2014
*/
#pragma once

#include <vector>

#include "Taurus_Util/Macros.h"
#include "Taurus_Util/TUTypes.h"
#include "Taurus_Viewer/StudyTitlebar.h"

//forward declarations
class CMonitorWnd;
class CODSeriesView;

/**
@brief study view class
*/
class CStudyView : public CWnd
{
	DECLARE_DYNAMIC(CStudyView)

private:
  DISALLOW_COPY_AND_ASSIGN(CStudyView);

public:
  /**
  @brief		default constructor
  */
	CStudyView();

  /**
  @brief		destructor
  */
	virtual ~CStudyView();

  /**
  @brief		attach monitor to the study view
  @param		monitorWnd pointer to monitor window
  @param    workArea work area
  @param    redraw flag indicating study view is to be redraw
  @return		ERROR_SUCCESS upon success, an error code otherwise
  */
  DWORD attachMonitor(const CMonitorWnd* monitorWnd,
                      const CRect& workRect,
                      BOOL redraw);

  /**
  @brief		detach monitor from the study view
  @param		redraw flag indicating study view is to be redraw
  @return		pointer to attached monitor window if study view attaches monitor window, nullptr if not
  */
  const CMonitorWnd* detachMonitor(BOOL redraw);

  /**
  @brief		access to attached monitor window
  @return		pointer to attached monitor window if study view attaches monitor window, nullptr if not
  */
  inline const CMonitorWnd* getMonitorWnd() const
  {
    return m_theMonitorWnd;
  }

  /**
  @brief		set title bar background and text color
  @param		bkColor background color
  @param    textColor text color
  @param    redraw flag indicating title bar is to be redrawn
  */
  void setTitlbarColor(const COLORREF& bkColor,
                       const COLORREF& textColor,
                       BOOL redraw);

  /**
  @brief		get title bar background and text color
  @param		bkColor background color
  @param    textColor text color
  */
  void getTitlebarColor(COLORREF& bkColor,
                        COLORREF& textColor) const;
private:
  /**
  @brief		arrange controls
  */
  void arrangeControls(void);

  /**
  @brief		create a ordinary series view
  @param		index the index number of ordinary series view
  @param    pSeriesView variable in which poiner to ordinary series view is stored
  @return		ERROR_SUCCESS upon success, an error code otherwise
  */
  DWORD createODSeriesView(unsigned int index, CODSeriesView*& pSeriesView);

private:

  //pointer to attached monitor window
  const CMonitorWnd* m_theMonitorWnd;

  //title bar
  CStudyTitlebar m_theTitlebar;

  //current series view layout
  C2DLayout m_theCurSeriesViewLayout;

  //ordinary series views
  std::vector<CODSeriesView*> m_theODSeriesViews;

protected:
	DECLARE_MESSAGE_MAP()
  afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  afx_msg void OnSize(UINT nType, int cx, int cy);
  afx_msg void OnPaint();
};


